package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmSensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmSensitiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: SensitiveController
 * Description:
 * date: 2023/8/22 0022 15:24
 *
 * @author zHan
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@Api(tags = "敏感词相关接口")
public class WmSensitiveController {

    @Autowired
    private WmSensitiveService wmSensitiveService;

    /**
     * 查询敏感词列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("查询敏感词列表")
    public ResponseResult list(@RequestBody WmSensitiveDto dto) {
        return wmSensitiveService.list(dto);
    }

    /**
     * 新增敏感词
     * @param wmSensitive
     * @return
     */
    @PostMapping("/save")
    @ApiOperation("新增敏感词")
    public ResponseResult save(@RequestBody WmSensitive wmSensitive) {
        return wmSensitiveService.saveSensitive(wmSensitive);
    }

    /**
     * 删除敏感词
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    @ApiOperation("删除敏感词")
    public ResponseResult delete(@PathVariable Integer id) {
        return wmSensitiveService.deleteSensitive(id);
    }

    /**
     * 修改敏感词
     * @param wmSensitive
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("修改敏感词")
    public ResponseResult update(@RequestBody WmSensitive wmSensitive) {
        return wmSensitiveService.updateSensitive(wmSensitive);
    }

}
